﻿using System;
using System.Diagnostics.Contracts;
using CardPlay.Model.ActionModel;

namespace CardPlay.Model.GameModel.Actions
{
    public abstract class GameAction : IAction
    {
        private readonly CardGame _game;

        protected GameAction(CardGame cardGame, PartLocation location)
        {
            Contract.Requires<ArgumentNullException>(cardGame != null, "game");
            
            _game = cardGame;
            Location = location;
        }
        
        public CardGame CardGame
        {
            get { return _game; }
        }

        public PartLocation Location { get; private set; }

        #region IGameAction Members

        public void Execute()
        {
            OnExecute();
        }
        
        public void Reverse()
        {
            OnReverse();
        }

        #endregion

        protected abstract void OnExecute();
        protected abstract void OnReverse();
    }
}
